# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=make

pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
_ver_base=4.0
pkgver=4.0.2289.432cb65
pkgrel=1
pkgdesc="GNU make utility to maintain groups of programs"
arch=('any')
url="http://www.gnu.org/software/make"
license=('GPL3')
groups=("${MINGW_PACKAGE_PREFIX}-toolchain")
depends=()
makedepends=('git' 'wget')
source=("$_realname"::'git://git.savannah.gnu.org/make.git'
        'make-getopt.patch'
        'make-linebuf-mingw.patch')
md5sums=('SKIP'
         '5ce314a61bbb0b5b0f1f4613babc83d2'
         'a6c10267a37c4ff2d48c697ca0580c3c')

pkgver() {
  cd "$srcdir/$_realname"
  printf "%s.%s.%s" "$_ver_base" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${srcdir}/${_realname}
  patch -p1 -i ${srcdir}/make-getopt.patch
  patch -p1 -i ${srcdir}/make-linebuf-mingw.patch
}

build() {
  cd ${srcdir}/${_realname}
  cmd /c 'build_w32.bat --without-guile gcc'
}

package() {
  cd ${srcdir}/${_realname}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
  cp -f gnumake.exe ${pkgdir}${MINGW_PREFIX}/bin/mingw32-make.exe
  cp -f libgnumake-1.dll.a ${pkgdir}${MINGW_PREFIX}/lib/
  cp -f gnumake.h ${pkgdir}${MINGW_PREFIX}/include/
}
